package com.cyk.comicforumjava.demos.web;

import com.cyk.comicforumjava.demos.base.ResponseResult;
import com.cyk.comicforumjava.demos.dto.*;
import com.cyk.comicforumjava.demos.service.ManageService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("/Manage")
public class ManageController {
    @Autowired
    private ManageService manageService;
    @PostMapping("getUserList")
    public ResponseResult getUserList(@RequestBody UserDto userDto){
        ResponseResult responseResult=manageService.getUserList(userDto.getUsername());
        return responseResult;
    }
    @PostMapping("getPostList")
    public ResponseResult getPostList(@RequestBody PostDto postDto) {
        ResponseResult responseResult=manageService.getPostList(postDto.getPostContent());
        return responseResult;
    }

    @PostMapping("getCommentList")
    public ResponseResult getCommentList(@RequestBody CommentDto commentDto) {
        ResponseResult responseResult=manageService.getCommentList(commentDto.getContent());
        System.out.println("评论的内容"+commentDto.getContent());
        return responseResult;
    }
    @PostMapping("getChatList")
    public ResponseResult getChatList(@RequestBody MessageDto messageDto) {
        ResponseResult responseResult=manageService.getChatList(messageDto.getContent());
        System.out.println("私信的内容"+messageDto.getContent());
        return responseResult;
    }

    @PostMapping("ban")
    public ResponseResult ban(@RequestBody UserDto userDto) {
        ResponseResult responseResult=manageService.banUser(userDto.getId());
        return responseResult;
    }
    @PostMapping("Noban")
    public ResponseResult unban(@RequestBody UserDto userDto) {
        ResponseResult responseResult=manageService.unBanUser(userDto.getId());
        return responseResult;
    }

    @PostMapping("deletePost")
    public ResponseResult deletePost(@RequestBody PostDto userDto) {
        ResponseResult responseResult=manageService.deletePost(userDto.getPostId());
        return responseResult;
    }

    @PostMapping("deleteComment")
    public ResponseResult deleteComment(@RequestBody CommentDto commentDto){
        ResponseResult responseResult=manageService.deleteComment(commentDto.getCommentId());
        return responseResult;
    }

    @PostMapping("deleteChat")
    public ResponseResult deleteChat(@RequestBody MessageDto messageDto){
        ResponseResult responseResult=manageService.deleteMessage(messageDto.getId());
        return responseResult;
    }

    @PostMapping("/getZoneList")
    public ResponseResult getZoneList(@RequestBody ZoneDto zoneDto){
        ResponseResult responseResult=manageService.getZoneList(zoneDto);
        return responseResult;
    }

    @PostMapping("/addZone")
    public ResponseResult addZone(@RequestBody ZoneDto zoneDto){
        ResponseResult responseResult=manageService.addZone(zoneDto);
        return responseResult;
    }

    @PostMapping("/deleteZone")
    public ResponseResult deleteZone(@RequestBody ZoneDto zoneDto){
        ResponseResult responseResult=manageService.deleteZone(zoneDto);
        return responseResult;
    }
    @PostMapping("/addSection")
    public ResponseResult addSection(@RequestBody SectionDto sectionDto){
        ResponseResult responseResult=manageService.addSection(sectionDto);
        return responseResult;
    }
    @PostMapping("/deleteSection")
    public ResponseResult deleteSection(@RequestBody SectionDto sectionDto){
        ResponseResult responseResult=manageService.deleteSection(sectionDto);
        return responseResult;
    }
}
